package MemberService

import (
	"context"
	"database/sql"
	toolsDb "gdshop-back-end-go/common/db"
	"gdshop-back-end-go/common/entity"
	"github.com/gogf/gf/errors/gerror"
)

func GetMemberModel(ctx context.Context, memberId int) (*entity.Member, error) {
	memberModel := (*entity.Member)(nil)
	err := toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "member").WherePri("id", memberId).Struct(&memberModel)
	if err != nil {
		if err == sql.ErrNoRows {
			return nil, gerror.NewCode(1000, "找不到会员数据")
		}
		return nil, err
	}

	return memberModel, nil
}
